﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../Content/js/angular1.2.13.js"></script>



</head>
<body ng-app="app" ng-controller="MyController">
    <div >
        <input ng-model="to" type="email" placeholder="Recipient" />
        <br/>
        <textarea ng-model="emailBody"></textarea>
        <pre>{{previewText}}</pre>
    </div>
    <script>
        angular.module('app',[])
        .controller('MyController', function ($scope, $interpolate) {
            //使得我们同时可以访问 $scope  $interpoate
            $scope.$watch('emailBody', function (body) {
                if (body) {
                    var template = $interpolate(body);
                    $scope.previewText = template({ to: $scope.to });
                }
            });
        })
    </script>
</body>
</html>
